package org.csu.myPetStore.service;

import org.csu.myPetStore.domain.Cart;
import org.csu.myPetStore.persistence.CartDAO;
import org.csu.myPetStore.persistence.impl.CartDAOImpl;

public class CartService {

    private CartDAO cartDAO;

    public CartService(){
        cartDAO = new CartDAOImpl();
    }

    public Cart getCartByUsername(String username){
        return cartDAO.getCartByUsername(username);
    };
    //通过用户名获取一个购物车

    public void deleteCartItemFromUserByItemId(String itemId,String username){
        cartDAO.deleteCartItemFromUserByItemId(itemId,username);
    };
    //通过itemId删除一个购物车中的item项

    public void insertCartItemByIremId(String itemId,int quantity,String username){
        cartDAO.insertCartItemByIremId(itemId,quantity,username);
    };
    //插入一个item到购物车
    public void deleteAllItemByUsername(String username){
        cartDAO.deleteAllItemByUsername(username);
    };

    public  int getQuantityByItemid(String itemId,String username){
        return cartDAO.getQuantityByItemid(itemId,username);
    }

    public void updateQuantityByItemid(int quantity,String itemId,String username){
        cartDAO.updateQuantityByItemid(quantity,itemId,username);
    }
}
